home *** CD-ROM | disk | FTP | other *** search
- { Tricky to get DBGrid display text for an arbitrary row }
- { Indicator and titles muck up dbgrid coordinate logic }
-
- unit Hints3U;
- {$ifdef Ver80} { Delphi 1.0x }
- {$define DelphiLessThan3}
- {$endif}
- {$ifdef Ver90} { Delphi 2.0x }
- {$define DelphiLessThan3}
- {$endif}
- {$ifdef Ver93} { C++ Builder 1.0x }
- {$define DelphiLessThan3}
- {$endif}
-
- interface
-
- uses
- WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms,
- Dialogs, Db, DBTables, DBGrids, DBHntGrd, Grids, HintGrid, StdCtrls,
- HintList;
-
- type
- TForm1 = class(TForm)
- HSG: THintStringGrid;
- HintDBGrid1: THintDBGrid;
- Table1: TTable;
- DataSource1: TDataSource;
- Table1CustNo: TFloatField;
- Table1Company: TStringField;
- Table1Addr1: TStringField;
- Table1Addr2: TStringField;
- Table1City: TStringField;
- Table1State: TStringField;
- Table1Zip: TStringField;
- Table1Country: TStringField;
- Table1Phone: TStringField;
- Table1FAX: TStringField;
- Table1TaxRate: TFloatField;
- Table1Contact: TStringField;
- Table1LastInvoiceDate: TDateTimeField;
- HintListBox1: THintListBox;
- chkTitles: TCheckBox;
- chkIndicator: TCheckBox;
- procedure FormCreate(Sender: TObject);
- procedure chkTitlesClick(Sender: TObject);
- procedure chkIndicatorClick(Sender: TObject);
- private
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- { Give string grids some values }
- procedure TForm1.FormCreate(Sender: TObject);
- var
- Loop, Loop2: Integer;
- const
- Text = 'The quick brown fox jumps over a lazy dog';
- begin
- for Loop := 1 to HSG.RowCount-1 do
- for Loop2 := 1 to HSG.ColCount-1 do
- HSG.Cells[Loop2, Loop] := Format('(%d, %d)', [Loop2, Loop]);
- for Loop := Length(Text) downto 1 do
- HintListBox1.Items.Add(Copy(Text, 1, Loop))
- end;
-
- procedure TForm1.chkTitlesClick(Sender: TObject);
- begin
- if chkTitles.Checked then
- HintDBGrid1.Options := HintDBGrid1.Options + [dgTitles]
- else
- HintDBGrid1.Options := HintDBGrid1.Options - [dgTitles]
- end;
-
- procedure TForm1.chkIndicatorClick(Sender: TObject);
- begin
- if chkIndicator.Checked then
- HintDBGrid1.Options := HintDBGrid1.Options + [dgIndicator]
- else
- HintDBGrid1.Options := HintDBGrid1.Options - [dgIndicator]
- end;
-
- end.
-